import axios from "axios";
const CheckLoginState = async (loginUser) => {
    if (loginUser == null || loginUser == "") {
        console.log("js-checkloginstate---未登入,或登入状态已失效");
        return {
            state: "-1",
            message: '未登入,或登入状态已失效!'
        }
    }else{
        const emailOrPhone = loginUser.email || loginUser.phone;
        const password = loginUser.password;
        const resp = await axios.post("http://localhost:8080/keepLogin", { "emailOrPhone": emailOrPhone, 'password': password });
        console.log("checkLoginUserState:",resp);
        if (resp.data.state == '3') {
            return {
                state:"3",
                message:resp.data.message
            }
        }

        if (resp.data.state == '0') {
            return {
                state:"0",
                loginUser:resp.data.loginUser
            }
        }
    }
}
export default CheckLoginState